export function timeDiffreence(date1, date2) {
	var date1 = date1;  //开始时间
	var date2 = date2;    //结束时间
	var date3 = new Date(date2).getTime() - new Date(date1).getTime();   //时间差的毫秒数      

	//------------------------------

	//计算出相差天数
	var days = Math.floor(date3 / (24 * 3600 * 1000))

	//计算出小时数

	var leave1 = date3 % (24 * 3600 * 1000)    //计算天数后剩余的毫秒数
	var hours = Math.floor(leave1 / (3600 * 1000))
	//计算相差分钟数
	var leave2 = leave1 % (3600 * 1000)        //计算小时数后剩余的毫秒数
	var minutes = Math.floor(leave2 / (60 * 1000))
	//计算相差秒数
	var leave3 = leave2 % (60 * 1000)      //计算分钟数后剩余的毫秒数
	var seconds = Math.round(leave3 / 1000)
	if (days > 0) {
		return days + "天" + hours + "小时" + minutes + "分钟" + seconds + "秒"
	}
	if (hours > 0) {
		return hours + "小时" + minutes + "分钟" + seconds + "秒"
	}
	if (minutes > 0) {
		return minutes + "分钟" + seconds + "秒"
	} else {
		return seconds + "秒"
	}
}

// export function format(){
Date.prototype.format = function (fmt) {
	var o = {
		"M+": this.getMonth() + 1,                 //月份 
		"d+": this.getDate(),                    //日 
		"h+": this.getHours(),                   //小时 
		"m+": this.getMinutes(),                 //分 
		"s+": this.getSeconds(),                 //秒 
		"q+": Math.floor((this.getMonth() + 3) / 3), //季度 
		"S": this.getMilliseconds()             //毫秒 
	};
	if (/(y+)/.test(fmt)) {
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	for (var k in o) {
		if (new RegExp("(" + k + ")").test(fmt)) {
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		}
	}
	return fmt;
}
// }